package com.jdkreader.concurrency.concurrent.simulation;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * 银行服务模拟器
 */
public class BankTellerSimulation {
    public static final int MAX_SIZE=50;
    public static final int ADJUSTMENT_PERIOD=1000;

    public static void main(String[] args) throws Exception{
        ExecutorService exec= Executors.newCachedThreadPool();
        CustomerLine customers=new CustomerLine(MAX_SIZE);
        //生成顾客
        exec.execute(new CustomerGenerator(customers));
        //生成服务员对象,同时调度服务员开始接待客人
        exec.execute(new TellerManager(exec,customers,ADJUSTMENT_PERIOD));
        TimeUnit.SECONDS.sleep(20);
        exec.shutdownNow();
    }
}
